package com.water.wl.newwater.adapter;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.water.wl.newwater.R;
import com.water.wl.newwater.bean.Tweet;
import com.water.wl.newwater.bean.WaterTest;
import com.water.wl.newwater.widget.AvatarView;


import junit.framework.Test;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by wds1993225 on 2016/3/11.
 */
public class TestAdapter extends ArrayAdapter<Tweet> {

    private int resourceId;


    public TestAdapter(Context context, int resource, List<Tweet> objects) {
        super(context, resource, objects);
        resourceId = resource;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        Tweet tweet = getItem(position);
        Log.i("位置",""+position);
        Log.i("内容",tweet.getAuthor());
        View view = LayoutInflater.from(getContext()).inflate(resourceId,null);
        //TextView textView = (TextView)view.findViewById(R.id.tv_tweet_name);
        TextView textView = (TextView)view.findViewById(R.id.tv_tweet_name);
        AvatarView avatarView = (AvatarView)view.findViewById(R.id.iv_tweet_face);
        avatarView.setAvatarUrl(tweet.getPortrait());

        textView.setText(tweet.getAuthor());
        return view;
    }
}
